package com.daluzy.chmanager.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.daluzy.chmanager.R;
import com.daluzy.chmanager.bean.Comment;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;

public class MyCommentAdapter extends RecyclerView.Adapter<MyCommentAdapter.MyViewHolder> {



    private Context context;
    private List<Comment> myData = new ArrayList<>();

    public MyCommentAdapter(Context context, List<Comment> myData) {
        this.context = context;
        this.myData = myData;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.adapter_feedback_item_daluzy, parent, false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        Comment comment = myData.get(position);
        holder.tvPerson.setText("评价对象：");
        holder.tvCommentDetails.setText(comment.getComment_details());
        holder.tvCommentLevel.setText(comment.getComment_level());
        holder.tvCommentStudent.setText(comment.getComment_employee());
        holder.tvTime.setText(comment.getCreatedAt());
        if (comment.getComment_status().equals("1")) {
            holder.tvCommentStatus.setText("未审核");
        } else if (comment.getComment_status().equals("2")) {
            holder.tvCommentStatus.setText("审核通过");
        } else {
            holder.tvCommentStatus.setText("审核失败");
        }
    }

    @Override
    public int getItemCount() {
        return myData.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.tv_person)
        TextView tvPerson;
        @BindView(R.id.tv_comment_student)
        TextView tvCommentStudent;
        @BindView(R.id.tv_comment_level)
        TextView tvCommentLevel;
        @BindView(R.id.tv_comment_details)
        TextView tvCommentDetails;
        @BindView(R.id.tv_time)
        TextView tvTime;
        @BindView(R.id.tv_comment_status)
        TextView tvCommentStatus;

        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
